#include <iostream>
#include <boost/format.hpp>
using namespace std;
using namespace boost;

int main()
{
    cout << format("%s: %d+%d=%d\n") % "sum" % 1 % 2 % (1+2);
    format fmt("(%1%+%2%)*%2%=%3%\n");
    fmt % 2 % 5;
    fmt % ((2+5)*5);
    cout << fmt;

    format name("My name is %|s|, and I am %|d| years old.\n");
    name % "John" % 23;
    cout << name;
    name.clear();
    name % "Hevake" % 26;
    cout << name;
    name.clear();
    name.bind_arg(1, "Li");
    name % 12;
    cout << name;
    name.clear();
    name % 16;
    cout << name;
    name.bind_arg(2, 23);
    cout << name;
    name % "Peter";
    cout << name;
    return 0;
}
